/**
 * 全局导航跳转工具类
 */
export default class NavigationUtil {
  /**
   * 跳转到指定页面
   * @param params 要传递的参数
   * @param page 要跳转的页面名称
   */
  static goPage = (params, page) => {
    const navigation = NavigationUtil.navigation;
    if (navigation) {
      navigation.navigate(page, {...params});
      return;
    }
    console.log('NavigationUtil.navigation can not be null');
  };

  /**
   * 返回上一页
   * @param navigation
   */
  static goBack = navigation => {
    navigation.goBack();
  };

  /**
   * 重置到首页
   * @param params
   */
  static resetToHomePage = params => {
    const {navigation} = params;
    if (navigation) {
      navigation.navigate('Home');
      return;
    }
    console.log('restToHomePage: navigation can not be null');
  };
}
